<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover" />
	<title>eventLoop</title>
</head>
<body>
<script>
/*
结果 1 9 12 2 3 5 8 10 11 4 6 7
同步任务 [
]
异步微任务 [
]
异步宏任务 [
]
*/

console.log(1)
setTimeout(() => {
	console.log(2)
	new Promise(resolve => {
		console.log(3)
		resolve();
		setTimeout(() => {
			console.log(4)
		})
	})
		.then(() => {
			new Promise((resolve, reject) => {
				console.log(5)
				setTimeout(() => {
					console.log(6)
					Promise.resolve().then(() => console.log(7))
				})
				resolve();
			})
				.then(res => {
					console.log(8)
				})
		});
})

new Promise((resolve, reject) => {
	console.log(9)
	setTimeout(() => {
		console.log(10)
		Promise.resolve().then(() => console.log(11))
	})
	resolve();
})
	.then(res => {
		console.log(12)
	})


</script>
</body>
</html>
